<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<canvas id="canvas"></canvas>
<script>
    //获取画布DOM对象
    var canvas = document.getElementById('canvas');
    //获取画笔（获取上下文）
    var ctx = canvas.getContext('2d');
    //指定填充颜色
    ctx.fillStyle = 'green';
    //绘制闭合路径
    ctx.fillRect(10, 10, 100, 100);
</script>
</body>
</html>
